import {hortgoods} from "../../utils/api"
export const state={
    list:[],
    alllist:[]
}

export const mutations={
    changehortgoods(state,arr){
        state.list=arr
    },
    changeallgoods(state,arr){
        state.alllist=arr
    }
}

export const actions={
    reqChangeHortgoods(context){
        hortgoods().then(res=>{
            var arr=[]
            arr.push(res.data.list[0].content)
            arr.push(res.data.list[1].content)
            arr.push(res.data.list[2].content)
            context.commit("changehortgoods",arr)
        })
    },
    reqChangeAllGoods(context){
        hortgoods().then(res=>{
            let arr1=res.data.list[0].content
            let arr2=res.data.list[1].content
            let arr3=res.data.list[2].content
            var arr= arr1.concat(arr2.concat(arr3))
            context.commit("changeallgoods",arr)
        })
    }
}

export const getters={
    list(state){
    return state.list
    },
    alllist(state){
        return state.alllist
    }
}

export default {
    state,
    actions,
    mutations,
    getters,
    namespaced:true,
}